// D8ReaderBeijing.h: interface for the D8ReaderBeijing class.
//
//////////////////////////////////////////////////////////////////////
#include "LoadDll.h"
#include "CardReaderInterface.h"

#if !defined(AFX_D8READERBEIJING_H__3C600273_6288_41EF_8D32_37923D64045B__INCLUDED_)
#define AFX_D8READERBEIJING_H__3C600273_6288_41EF_8D32_37923D64045B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class D8ReaderBeijing  
{
protected:
	HANDLE m_hReader;
	HINSTANCE m_DllHandle;	
	int m_ReaderPort;
	int m_line;

	unsigned char m_SW[5];
	
	unsigned char m_RespBuf[601];
	
	CardDataLog *m_pCardApduLog;
	
	unsigned char m_snr[15];
	
	DC_init f_dc_init;
	DC_exit f_dc_exit;
	DC_reset f_dc_reset;
	DC_halt f_dc_halt;
	DC_card_hex f_dc_card_hex;
	DC_pro_reset_hex f_dc_pro_reset_hex;
	DC_pro_command_hex f_dc_pro_command_hex;
	A_hex f_a_hex;
	DC_beep f_dc_beep;
	DC_cpuapduEXT_hex f_dc_cpuapduEXT_hex;
	DC_pro_commandlinkEXT_hex f_dc_pro_commandlinkEXT_hex;
public:
	D8ReaderBeijing(int readerPort);
	~D8ReaderBeijing();

	FARPROC loadFun(CString FunName);
	int loadFunAll(int readerPort);

	void setApduLog(CardDataLog* pApduLog) {
		m_pCardApduLog = pApduLog;
	};
	CardDataLog* getApduLog() {
		return m_pCardApduLog;
	};

	BOOL G3_Open(int iPort);
	void G3_Close();
	int  G3_Reset(DWORD &len,LPBYTE resp);
	int  G3_APDU(DWORD &len,LPBYTE comm);
	int  G3_Command(DWORD &nCosLen,BYTE *pCosCmd);
	void G3_setReadHand(HANDLE hread);
	int getReaderStatus();
};

// int __stdcall CardCommand(int sChannelID,DWORD &nCosLen,BYTE *pCosCmd);
// int __stdcall CardReset(int sChannelID,DWORD &nCosLen,BYTE *pCosCmd);
// 
// int __stdcall IcLock();
// int __stdcall IcUnLock();

#endif // !defined(AFX_D8READERBEIJING_H__3C600273_6288_41EF_8D32_37923D64045B__INCLUDED_)
